package com.example.base.activity;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager.widget.ViewPager;

import android.os.Bundle;

import com.example.base.adapter.MineViewPager;
import com.example.base.R;
import com.example.base.fragment.LoginFragment;
import com.example.base.fragment.RegisterFragment;

import java.util.ArrayList;
import java.util.List;

public class LoginActivity extends FragmentActivity {
  ViewPager mcContainer;
  private List<Fragment> fragmentList;


  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    initView();
    initViewPager();
  }

  private void initViewPager() {
    fragmentList.add(new LoginFragment());
    fragmentList.add(new RegisterFragment());
    mcContainer.setAdapter(new MineViewPager(getSupportFragmentManager(), fragmentList));
  }

  private void initView() {
    setContentView(R.layout.activity_login);
    mcContainer = findViewById(R.id.viewpager_login);
    fragmentList = new ArrayList<>();
  }

  public void chageViewPager(int page) {
    mcContainer.setCurrentItem(page);
  }

}